package b3.widget.home.social
{
	import b3.config.*;
	import b3.model.*;
	import b3.net.*;
	import b3.util.*;
	import b3.widget.basic.*;
	import b3.widget.tab.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;
	import flash.text.*;

	public class SocialInfoDialog extends Tab
	{
		public function SocialInfoDialog()
		{
			//背景
			var PaneBgr:Class = ResourceHelper.getInstance().getClassByName("MessageBoxBgr");
			var pangBgr:Sprite = new PaneBgr();
			pangBgr.width = 520;
			pangBgr.scaleY = pangBgr.scaleX;
			addChild(pangBgr);
			super("", 1, 5);
			var TabPageFirstPage:Class = ResourceHelper.getInstance().getClassByName("TabPageFirstPage3");
			var TabPagePageUp:Class = ResourceHelper.getInstance().getClassByName("TabPagePageUp3");
			var TabPagePageDown:Class = ResourceHelper.getInstance().getClassByName("TabPagePageDown3");
			var TabPageLastPage:Class = ResourceHelper.getInstance().getClassByName("TabPageLastPage3");
			setPageSelectorStyle(TabPageFirstPage, TabPagePageUp, TabPagePageDown, TabPageLastPage, 0x66FF, 0x66FF);
			//设置页码位置
			this.setPagePos(62, 80);
			this.setPageSelectorPos(257, 278);
			//标题
			var titleField:TextField = new TextField();
			titleField.selectable = false;
        	titleField.autoSize = TextFieldAutoSize.CENTER;
			titleField.defaultTextFormat = new TextFormat(BFont.fontName, 20, 0xFFFFFF, true);
			titleField.filters = [new GlowFilter(0x00AAFF, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			titleField.x = this.width / 2;
			titleField.y = 30;
			titleField.text = "社交信息";
			addChild(titleField);
			
			//关闭按钮
			var CloseButton:Class = ResourceHelper.getInstance().getClassByName("CloseButton1");
			var closeButton:BasicButton = new BasicButton(CloseButton);
			closeButton.x = (this.width - closeButton.width) / 2;
			closeButton.y = 312;
			addChild(closeButton);
			closeButton.addEventListener(MouseEvent.CLICK, onCloseButtonClick);
			
			var me:Player = PlayerManager.getInstance().me;
			var socialInfos:Array = me.socialInfos;
			for (var i:int = 0; i < socialInfos.length; i++)
			{
				var socialItem:SocialInfoItem = new SocialInfoItem(socialInfos[i]);
				addItem(socialItem, 394.35, 34.85);
			}
			
			this.anchor = BasicWidget.ANCHOR_MIDDLE_MIDDLE;
			this.x = -this.width / 2;
			this.y = -this.height / 2;
			
			this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		}

		private function onAddedToStage(event:Event):void
		{
			var me:Player = PlayerManager.getInstance().me;
			me.setSocialInfoViewed();
		}

		private function onCloseButtonClick(event:Event):void
		{
			close();
		}
		
	}
}